import { request } from '@/utils/request';

let url = 'http://localhost:5177';

export const fileApi = {
  // 获取文件列表
  getFileList: (params) => request('get', `${url}/api/file`, { params }),

  // 上传文件
  uploadFile: (formData, onUploadProgress) => request('post', `${url}/api/file/upload`, formData, {
    headers: { 'Content-Type': 'multipart/form-data' },
    onUploadProgress
  }),

  // 直接下载文件（返回文件流）
  downloadFile: (fileId) => request('get', `${url}/api/file/${fileId}/download-file`, {}, {
    responseType: 'blob'
  }),

  // 获取文件下载链接
  getDownloadLinks: (fileId) => request('get', `${url}/api/file/${fileId}/download-links`),

  // 删除文件
  deleteFile: (fileId) => request('delete', `${url}/api/file/${fileId}`),

  // 获取文件详情
  getFileDetail: (fileId) => request('get', `${url}/api/file/${fileId}`),

  // 更新文件信息
  updateFileInfo: (fileId, data) => request('put', `${url}/api/file/${fileId}`, data)
};
